<template>
  <el-drawer v-model="drawer" title="关联人员" size="50%">
    <el-form
      class="-mb-15px"
      :model="queryParams"
      ref="queryOrderFormRef"
      :inline="true"
      label-width="100px"
    >
      <!-- <el-form-item label="业务分账人" prop="orderCode">
        <el-input v-model="queryParams.orderCode" placeholder="请输入订单号" />
      </el-form-item>
      <el-form-item>
        <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
        <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
      </el-form-item> -->
    </el-form>
    <el-table :data="orderList" :stripe="true" :show-overflow-tooltip="true">
      <el-table-column label="业务分账人" align="center" prop="userName" />
      <el-table-column label="分账总金额(元)" align="center">
        <template #default="scope">
          {{ (scope.row.dividePrice / 100).toFixed(2) }}
        </template>
      </el-table-column>
      <el-table-column label="分账订单数量" align="center" prop="orderCount" />
    </el-table>
    <Pagination
      :total="orderTotal"
      v-model:page="orderQueryParams.pageNo"
      v-model:limit="orderQueryParams.pageSize"
      @pagination="getOrderList"
    />
  </el-drawer>
</template>
<script setup lang="ts">
import { DICT_TYPE, getIntDictOptions, getStrDictOptions } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime'
import * as DivideApi from '@/api/meijia/divide'
const { t } = useI18n() // 国际化
const message = useMessage() // 消息弹窗
const queryParams = reactive({
  pageNo: 1,
  pageSize: 10,
  name: undefined
})
const dialogVisible = ref(false) // 弹窗的是否展示
const activeName = ref('first')
const drawer = ref(false)
const queryOrderFormRef = ref() // 搜索的表单
const orderList = ref([]) // 订单列表
const orderTotal = ref(0) // 订单列表的总页数
const orderQueryParams = reactive({
  pageNo: 1,
  pageSize: 10,
  divideAllCode: undefined,
  memberCode: undefined
})
const divideCode = ref('')
/** 打开弹窗 */
const open = async (code: string) => {
  drawer.value = true
  divideCode.value = code
  await getOrderList()
}

const getOrderList = async () => {
  const param = { divideAllCode: divideCode.value }
  const data = await DivideApi.getDivideResultByUser(param)
  orderList.value = data.list
  orderTotal.value = data.total
}
/** 搜索按钮操作 */
const handleQuery = () => {
  queryParams.pageNo = 1
  getOrderList()
}

/** 重置按钮操作 */
const resetQuery = () => {
  queryOrderFormRef.value.resetFields()
  handleQuery()
}
defineExpose({ open }) // 提供 open 方法，用于打开弹窗
</script>
<style scoped>
.el-select {
  width: 100%;
}
.info_item,
.mr-5px {
  margin-right: 10px;
}
.img {
  margin-left: 20px;
}
</style>
